package gerardoapps;

import sistemas.sam.R;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.Toast;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.TextView;

public class BusquedaAlumno extends Activity implements OnClickListener{

	
	String idM,idG,idU,method;
	Button buscar;
	TextView text;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.busqueda_alumno);
		
		
Bundle bundle=getIntent().getExtras();
		
		
		idM=""+bundle.getString("idm");
		idG=""+bundle.getString("idg");
		idU=""+bundle.getString("idunidad");
		
		text=(TextView) findViewById(R.id.nombre);
		
		buscar=(Button) findViewById(R.id.buscar);
		buscar.setOnClickListener(this);

		
		
	}

		
		
		
	
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		ServerAccess ss=new ServerAccess();
		
		
		if(text.getText().toString().trim().equals("")){
			Toast.makeText(getApplicationContext(), "Por favor Ingrese \n La matricula o nombre del alumno \n A buscar", Toast.LENGTH_LONG).show();
			
		}
		
		else{
			String id=""+text.getText().toString();
			String mat=ss.ReturnMatriculaAlum(id);
			String nom=ss.ReturnNombreAlum(id);
			
			if(mat.equals("No existe") && nom.equals("No existe")){
				Toast.makeText(getApplicationContext(), "No el alumno no existe", Toast.LENGTH_LONG).show();	
			}
			else{
		    method="Modificar";
			Toast.makeText(getApplicationContext(), "Alumno :"+nom+" Mat: "+mat, Toast.LENGTH_LONG).show();	
			Intent i =new Intent(this,Calificaciones_Alumn.class);
			Bundle bundle = new Bundle();
			bundle.putString("nombreA",nom);
			bundle.putString("matriA",mat);
			bundle.putString("IDm", idM);
	        bundle.putString("IDu", idU);
	        bundle.putString("IDg", idG); 
	        bundle.putString("method", method);
	        i.putExtras(bundle);
			startActivity(i);
			}
		}
	}


}
